<template>
	<view class="index">
		<sww-search :custom-style="{ paddingBottom: '12rpx' }" keyWord="prod" @change="onSearch"
			historyKey="info_search_history">

		</sww-search>


		<info-list :dataList="dataList" :parameter="{layout:2}"></info-list>

		<sww-load-more :params="dataListParams" @load="loadMore"></sww-load-more>
	</view>
</template>

<script>
	import {
		pagingMixin
	} from '@/mixins/pagingMixin.js';
	import infoList from '@/pagecomponents/informationList/index.vue'
	export default {
		mixins: [pagingMixin],
		components: {
			'info-list': infoList
		},
		data() {
			return {
				categoryId: null,
				business_id: null,
				searchKey: ''
			};
		},
		onReachBottom: function() {
			this.loadMore();
		},
		onLoad(options) {
			uni.setNavigationBarTitle({
				title: options.title || '资讯'
			});
			if (options && options.id) {
				this.categoryId = Number(options.id);
			}
			if (options && options.business_id && options.business_id > 0) {
				this.business_id = Number(options.business_id);
			}
			this.initPage();
		},
		methods: {
			initPage() {
				let params = {
					type: 2,
					name: this.searchKey || ''
				};
				if (this.categoryId) {
					params.common_type = this.categoryId;
				}
				if (this.business_id) {
					params.business_id = this.business_id
				}
				this._init_data('GetInfotainmentList', params);
			},
			// 确定搜索/清空：搜索
			onSearch(searchKey) {
				this.searchKey = searchKey;
				this.dataList = []
				this.$nextTick(() => {
					this.initPage()
				});
			},
			loadMore() {
				this._load_data();
			},
			goDetail(item) {
				this.$linkTo(`/package/league/detail/index?id=${item.pk_id}`, 'navigateTo');
			}
		}
	};
</script>

<style lang="scss" scoped>
	.index {
		.invite-list {
			padding: 24rpx;

			.invite-item {
				width: 100%;
				height: 220rpx;
				padding: 40rpx 0;
				position: relative;
				display: flex;

				&::after {
					content: '';
					width: 100%;
					height: 1rpx;
					border-bottom: 1rpx solid #eaeaea;
					position: absolute;
					left: 0;
					bottom: 0;
					transform: scaleY(0.5);
				}

				.invite-left {
					flex: 1;
					overflow: hidden;
					margin-right: 28rpx;
					display: flex;
					flex-direction: column;
					justify-content: space-between;

					.invite-title {
						font-size: 28rpx;
						-webkit-line-clamp: 2;
						display: -webkit-box;
						overflow: hidden;
						text-overflow: ellipsis;
						-webkit-box-orient: vertical;
					}

					.invite-bottom {
						.invite-date {
							font-size: 24rpx;
							color: #999999;
						}

						.invite-view {
							font-size: 24rpx;
							color: #999999;
							margin-left: 20rpx;
						}
					}
				}

				.invite-right {
					width: 225rpx;
					height: 100%;
					border-radius: 10rpx;
				}
			}
		}
	}
</style>
